<template>
  <div class="showBtn">
    <el-row>
      <el-button @click="showShopDetails(productId)">查看详情</el-button>
      <el-button type="primary"
                 @click="addCart(productId,productPrice,productName,productImg)">加入购物车</el-button>
    </el-row>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  props: ['productId', 'productPrice', 'productName', 'productImg'],
  computed: {
    ...mapState(['login'])
  },
  methods: {
    async showShopDetails(productId) {
      this.$router.push({
        path: `shopDetails?productId=${productId}`
      })
    },
    addCart(id, price, name, img) {
      if (this.login) {
        // 用户已登录
      }
    }
  }
}
</script>
<style lang="less" scoped>
.showBtn {
  position: absolute;
  width: 100%;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
}
</style>
